<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">申请信用卡统计</ui:define>
    <ui:define name="content">
        <h:form>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"/>
                        <p:commandButton value="重置" icon="fa fa-refresh" update="@form"
                                         actionListener="#{statNewCreditCardUvBean.onRest()}"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="xls" target="credit-card-stat-list" fileName="credit-card-statistics"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            <h1>查询条件</h1>

                            <div class="ui-g-1">
                                <p:outputLabel  value="日期"/>
                            </div>
                            <div class="ui-g-2">
                                <p:calendar value="#{statNewCreditCardUvBean.$.beginDate}"
                                            styleClass="autoWidthCalendar"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            readonlyInput="true"/>
                                <span>—</span>
                                <p:calendar value="#{statNewCreditCardUvBean.$.endDate}"
                                            styleClass="autoWidthCalendar"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATE_FORMAT')}"
                                            readonlyInput="true"/>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel  value="产品"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu filter="true" filterMatchMode="startsWith"  value="#{statNewCreditCardUvBean.$.prdid}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItems value="#{statNewCreditCardUvBean.getCommProductIds()}" var="commProduct"
                                                   itemLabel="#{commProduct.name}" itemValue="#{commProduct.productId}"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel  value="渠道"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu filter="true" filterMatchMode="startsWith"  value="#{statNewCreditCardUvBean.$.channel}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItems value="#{statNewCreditCardUvBean.getCommProductChannels()}"
                                                   var="commChannel"
                                                   itemLabel="#{commChannel.channelName}"
                                                   itemValue="#{commChannel.channelCode}"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel  value="用户类型"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu filter="true" filterMatchMode="startsWith"  value="#{statNewCreditCardUvBean.$.userType}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItem itemLabel="新用户" itemValue="1" />
                                    <f:selectItem itemLabel="老用户" itemValue="0" />
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="入口"/>
                            </div>
                            <div class="ui-g-2">
                                <p:selectOneMenu  value="#{statNewCreditCardUvBean.$.entrance}">
                                    <f:selectItem itemLabel="全部" itemValue="" />
                                    <f:selectItems  value="#{statNewCreditCardUvBean.dictionaries[DictionaryCode.NEW_CREDIT_CARD_ADVERT]}"
                                                    var="dic"
                                                    itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="信用卡名称"/>
                            </div>
                            <div class="ui-g-2">
                                <p:chips value="#{statNewCreditCardUvBean.$.nameList}"/>
                            </div>


                        </div>
                        <div class="card ui-g-12">
                            <p:dataTable id="credit-card-stat-list"
                                         style="width: 100%;text-align: center"
                                         var="record"
                                         value="#{statNewCreditCardUvBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         reflow="true"
                                         resizableColumns="true">

                                <p:column headerText="时间">
                                    <h:outputText value="#{record.intoDate}"/>
                                </p:column>
                                <p:column headerText="产品">
                                    <h:outputText value="#{record.prdid}"/>
                                </p:column>
                                <p:column headerText="渠道">
                                    <h:outputText value="#{record.channel}"/>
                                </p:column>
                                <p:column headerText="用户类型">
                                    <h:outputText value="#{record.userType ==1 ? '新用户':'老用户'}"/>
                                </p:column>
                                <p:column headerText="入口">
                                    <h:outputText value="#{statNewCreditCardUvBean.translate(DictionaryCode.NEW_CREDIT_CARD_ADVERT,record.entrance)}"/>
                                </p:column>
                                <p:column headerText="办卡首页uv">
                                    <h:outputText value="#{record.homeUv}"/>
                                </p:column>
                                <p:column headerText="信用卡名称">
                                    <h:outputText value="#{record.cardName}"/>
                                </p:column>
                                <p:column headerText="详情uv">
                                    <h:outputText value="#{record.detailUv}"/>
                                </p:column>
                                <p:column headerText="点击申请uv">
                                    <h:outputText value="#{record.clickApplyUv}"/>
                                </p:column>
                                <p:column headerText="返现登记uv">
                                    <h:outputText value="#{record.retCashUv}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
